package com.xinqing.test.LetCode;

/**
 * @Author:CHQ
 * @Date:2021/7/21 14:17
 * @Description
 */
public class IsBalanced {
    public static void main(String args[]){
        TreeNode root=new TreeNode(1);
        TreeNode l=new TreeNode(2);
        TreeNode r=new TreeNode(3);
        root.left=l;
        root.right=r;

        if(Math.abs(test(root.left)-test(root.right))<=1){
            System.out.println("true");
        }else{
            System.out.println("false");
        }
    }
    public static int test(TreeNode root){
        if(root==null){
            return 0;
        }

        return Math.max(test(root.left),test(root.right))+1;
    }
}
